//
//  UploadUserPhotoBottomView.m
//  ChatForHot
//
//  Created by wr on 2018/10/15.
//  Copyright © 2018年 FLY. All rights reserved.
//

#import "UPhotoBottomView.h"

@implementation UPhotoBottomView

- (instancetype)initWithFrame:(CGRect)frame {
    if (self = [super initWithFrame:frame]) {
        [self HOTCHATdidInitialized];
    }
    return self;
}

- (void)HOTCHATdidInitialized {
    [self addSubview:self.HOTCHATclickBtn];
    [self addSubview:self.HOTCHATnameLab];
    [self addSubview:self.HOTCHATarrowImgView];
    //        [self addSubview:self.HOTCHATpreviewButton];
    [self addSubview:self.HOTCHATlineview];
    
    [self.HOTCHATnameLab mas_updateConstraints:^(MASConstraintMaker *make) {
        make.left.top.bottom.equalTo(self.HOTCHATclickBtn);
    }];
    [self.HOTCHATarrowImgView mas_updateConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.HOTCHATnameLab.mas_right).offset(10);
        make.centerY.equalTo(self.HOTCHATnameLab);
    }];
    [self.HOTCHATclickBtn mas_updateConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self).offset(15);
        make.top.equalTo(self).offset(5);
        make.bottom.equalTo(self).offset(-5);
        make.right.equalTo(self.HOTCHATarrowImgView).offset(10);
    }];
    //        [self.HOTCHATpreviewButton mas_updateConstraints:^(MASConstraintMaker *make) {
    //            make.top.bottom.equalTo(self.HOTCHATclickBtn);
    //            make.right.equalTo(self).offset(-15);
    ////            make.width.mas_equalTo(50);
    //        }];
    [self.HOTCHATlineview mas_updateConstraints:^(MASConstraintMaker *make) {
        make.top.left.right.equalTo(self);
        make.height.mas_equalTo(0.5);
    }];
}

#pragma mark - Actions
- (void)showListview{
    if (self.delegate && [self.delegate respondsToSelector:@selector(HOTCHATsetListShow)]) {
        [self.delegate HOTCHATsetListShow];
    }
}

- (void)setIsShowList:(BOOL)isShowList{
    _isShowList = isShowList;
    [UIView animateWithDuration:0.25 animations:^{
        if (isShowList) {
            self.HOTCHATarrowImgView.transform = CGAffineTransformMakeRotation(M_PI);
        }else{
            self.HOTCHATarrowImgView.transform = CGAffineTransformMakeRotation(M_PI * 2);
        }
    }];
}


- (void)setPhotoName:(NSString *)photoName{
    _photoName = photoName;
    self.HOTCHATnameLab.text = photoName;
}

- (UIButton *)HOTCHATclickBtn{
    if (_HOTCHATclickBtn == nil) {
        _HOTCHATclickBtn = [[UIButton alloc] init];
        [_HOTCHATclickBtn addTarget:self action:@selector(showListview) forControlEvents:(UIControlEventTouchUpInside)];
    }
    return _HOTCHATclickBtn;
}

- (UILabel *)HOTCHATnameLab{
    if (_HOTCHATnameLab == nil) {
        _HOTCHATnameLab = [[UILabel alloc] init];
        _HOTCHATnameLab.font = [UIFont systemFontOfSize:15];
        _HOTCHATnameLab.textColor = [UIColor colorFromHexString:@"1A1A1A"];
    }
    return _HOTCHATnameLab;
}

- (UIImageView *)HOTCHATarrowImgView{
    if (_HOTCHATarrowImgView == nil) {
        _HOTCHATarrowImgView = [[UIImageView alloc] init];
        _HOTCHATarrowImgView.image = [UIImage imageNamed:@""];
    }
    return _HOTCHATarrowImgView;
}

- (UIButton *)HOTCHATpreviewButton{
    if (_HOTCHATpreviewButton == nil) {
        _HOTCHATpreviewButton = [[UIButton alloc] init];
        [_HOTCHATpreviewButton setTitle:@"Preview" forState:(UIControlStateNormal)];
        UIColor *color = [UIColor colorFromHexString:@"1A1A1A"];
        [_HOTCHATpreviewButton setTitleColor:color forState:(UIControlStateNormal)];
    }
    return _HOTCHATpreviewButton;
}
- (UIView *)HOTCHATlineview{
    if (_HOTCHATlineview == nil) {
        _HOTCHATlineview = [[UIView alloc] init];
        _HOTCHATlineview.backgroundColor = [UIColor colorFromHexString:@"EDEDED"];
    }
    return _HOTCHATlineview;
}
@end
